package controllers

import (
	"fmt"

	"github.com/beego/beego/v2/client/orm"
	beego "github.com/beego/beego/v2/server/web"
)

type BeSellerController struct {
	beego.Controller
}

func (c *BeSellerController) Get() {
	username := c.GetSession("username")
	if username == nil {
		c.Redirect("/", 302)
	}

	c.TplName = "beSellerGet.tpl"
}

func (c *BeSellerController) Post() {
	username := c.GetSession("username")
	if username == nil {
		c.Redirect("/user/beSeller", 302)
	}
	authority := c.GetSession("authority")
	seller_Id := c.GetSession("user_Id")
	fmt.Println(username, authority)
	shopName := c.GetString("shopname")
	social_Id := c.GetString("social_id")
	realName := c.GetString("name")
	introduction := c.GetString("introdution")
	o := orm.NewOrm()
	o.Raw("INSERT INTO  shop (seller_Id, introduction, shopName, social_Id,realName,shopState) VALUES (?,?,?,?,?,?);", seller_Id, introduction, shopName, social_Id, realName, 0).Exec()

	c.TplName = "beSellerPost.tpl"
}
